<template>
    <a-card :bordered="false">
      <div>
        <a-table
          ref="table"
          size="middle"
          :scroll="{x:true}"
          bordered
          rowKey="id"
          :columns="columns"
          :dataSource="dataSource"
          :pagination="ipagination"
          :loading="loading"
          class="j-table-force-nowrap"
          @change="handleTableChange">
          <template slot="htmlSlot" slot-scope="text">
            <div v-html="text"></div>
          </template>
          <template slot="imgSlot" slot-scope="text,record">
            <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
            <img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
          </template>
          <template slot="fileSlot" slot-scope="text">
            <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
            <a-button
              v-else
              :ghost="true"
              type="primary"
              icon="download"
              size="small"
              @click="downloadFile(text)">
              下载
            </a-button>
          </template>
          <span slot="status" slot-scope="text, record, index">
            <a-tag color="pink" v-if="text==0">待审核</a-tag>
            <a-tag color="#87d068" v-if="text==1" >通过</a-tag>
            <a-tag color="#e70a0a" v-if="text==2" >未通过</a-tag>
        </span>
          <span slot="action" slot-scope="text, record">

        </span>
        </a-table>
      </div>
    </a-card>
</template>

<script>

import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { deleteAction, getAction } from '@api/manage'


export default {
  name: 'UserhomeBankListModal',
  mixins:[JeecgListMixin, mixinDevice],
  props: {
    userhomeId: {
      type: Number,
      default: ''
    },
  },
  components: {
  },
  data () {
    return {
      description: '银行卡列表',
      // 表头
      columns: [
        {
          title:'持卡人姓名',
          align:"center",
          dataIndex: 'accountName'
        },
        {
          title:'银行名称',
          align:"center",
          dataIndex: 'bankName'
        },
        {
          title:'银行预留电话',
          align:"center",
          dataIndex: 'phone'
        },
        {
          title:'持卡人卡号',
          align:"center",
          dataIndex: 'bankNumber'
        },
        {
          title:'银行卡正面',
          align:"center",
          dataIndex: 'bankBeforeUrl',
          scopedSlots: { customRender: 'imgSlot' }
        },
        {
          title:'银行卡反面',
          align:"center",
          dataIndex: 'bankAfterUrl',
          scopedSlots: { customRender: 'imgSlot' }
        },
        {
          title:'创建时间',
          align:"center",
          dataIndex: 'createtime',
          customRender:function (text) {
            return !text?"":(text.length>10?text.substr(0,10):text)
          }
        },
        {
          title:'状态',
          align:"center",
          dataIndex: 'status',
          scopedSlots: { customRender: 'status' }
        }
      ],
      url: {
        list: "/bank/ycUserhomeBank/list",
      },
      title:"银行卡列表",
      dictOptions:{},
      superFieldList:[],
    }
  },
  created() {
    this.getSuperFieldList();
  },
  computed: {
    importExcelUrl: function(){
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    },
  },
  methods: {
    initDictConfig(){
    },
    loadData(arg) {
      if (!this.url.list) {
        this.$message.error("请设置url.list属性!")
        return
      }
      if (this.userhomeId == null || this.userhomeId == "") {
        return
      }
      this.queryParam.userhomeId = this.userhomeId;
      //加载数据 若传入参数1则加载第一页的内容
      if (arg === 1) {
        this.ipagination.current = 1;
      }
      var params = this.getQueryParams();//查询条件
      this.loading = true;
      getAction(this.url.list, params).then((res) => {
        if (res.success) {
          //update-begin---author:zhangyafei    Date:20201118  for：适配不分页的数据列表------------
          this.dataSource = res.result.records || res.result;
          if (res.result.total) {
            this.ipagination.total = res.result.total;
          } else {
            this.ipagination.total = 0;
          }
          //update-end---author:zhangyafei    Date:20201118  for：适配不分页的数据列表------------
        } else {
          this.$message.warning(res.message)
        }
      }).finally(() => {
        this.loading = false
      })
    },
    getSuperFieldList(){
      let fieldList=[];

      this.superFieldList = fieldList
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>